'Copyright (c) 2009 Grailtek

'Permission is hereby granted, free of charge, to any person
'obtaining a copy of this software and associated documentation
'files (the "Software"), to deal in the Software without
'restriction, including without limitation the rights to use,
'copy, modify, merge, publish, distribute, sublicense, and/or sell
'copies of the Software, and to permit persons to whom the
'Software is furnished to do so, subject to the following
'conditions:

'The above copyright notice and this permission notice shall be
'included in all copies or substantial portions of the Software.

'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
'EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
'OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
'NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
'HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
'WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
'FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
'OTHER DEALINGS IN THE SOFTWARE.

Imports System.Collections.Generic
Imports System.Xml
Imports System.Xml.Serialization
Imports System.Reflection
Imports System.Text

Partial Structure Contract

    <Serializable()> _
    Public Structure OutputSignature
        Implements IEquatable(Of OutputSignature)
        Implements IXmlSerializable

        Public Multiple As Boolean
        Public Parameters() As Parameter

        Public Sub New(ByVal iParameters() As Parameter, ByVal iMultiple As Boolean)
            Multiple = iMultiple
            Parameters = iParameters
        End Sub

        Public Overloads Function Equals(ByVal other As OutputSignature) As Boolean Implements System.IEquatable(Of OutputSignature).Equals
            Dim ret As Boolean = True
            ret = ret AndAlso Me.Multiple = other.Multiple
            ret = ret AndAlso Parameter.CompareSets(Me.Parameters, other.Parameters)
            Return ret
        End Function

        Public Function GetSchema() As System.Xml.Schema.XmlSchema Implements System.Xml.Serialization.IXmlSerializable.GetSchema
            Return Nothing
        End Function

        Public Const MultNode As String = "Multiple"

        Public Sub ReadXml(ByVal reader As System.Xml.XmlReader) Implements System.Xml.Serialization.IXmlSerializable.ReadXml
            Try
                reader.MoveToContent()
                reader.ReadToDescendant(MultNode)
                Multiple = Boolean.Parse(reader.ReadInnerXml)
                reader.MoveToContent()
                Dim sigcontent As String = reader.ReadInnerXml
                Me.Parameters = Parameter.DeserialzeSet(sigcontent)
            Finally
                reader.ReadEndElement()
            End Try
        End Sub

        Public Sub WriteXml(ByVal writer As System.Xml.XmlWriter) Implements System.Xml.Serialization.IXmlSerializable.WriteXml
            writer.WriteStartElement(MultNode)
            writer.WriteRaw(Multiple.ToString)
            writer.WriteEndElement()
            Parameter.SerialzeSet(writer, Me.Parameters)
        End Sub

    End Structure

End Structure